import smtplib
from email.mime.text import MIMEText

email_host = 'smtp.163.com'   # 163邮箱服务器地址
email_user = '15030274136@163.com'  # 发送者账号
email_pwd = '625216'               # 发送者密码
areceivers = '17610769836@163.com,cuixuetao@xiangshang360.com' # 收件人邮箱,多个账号用,号隔开
# acc = '15030374135@163.com,956039309@qq.com'


me = email_user
msg = MIMEText('this is a test email')  # 邮件内容(一般是msg.as_string():as_string()是将msg(MIMEText对象或者MIMEMultipart对象)变为str)
msg['Subject'] = 'new'    # 邮件主题
msg['From'] = me               # 发送者账号
msg['To'] = areceivers           # 接收者账号列表
# msg['Cc'] = acc

smtp = smtplib.SMTP(email_host, port=25)  # 链接邮箱,传入邮箱地址和端口号,SMTP的端口号是25
smtp.login(email_user, email_pwd)          # 发送者的邮箱账号,密码
smtp.sendmail(me, areceivers.split(','), msg.as_string())  # 参数分别是发送者,接收者(字符串列表['接收地址1','接收地址2','接收地址3',...]或'接收地址'),第三个是把上面的发送邮件的内容变成字符串
smtp.quit()    # 发送完毕退出smtp
print('email send success')

